package br.edu.ifmg.ada.controller;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import br.edu.ifmg.ada.R;

public class MainListAdapter extends BaseAdapter{
	
	private LayoutInflater mInflater;
	private ArrayList<ItemMainList> itens;
	
	public MainListAdapter(Context context, ArrayList<ItemMainList> itens){
		this.itens = itens;
		this.mInflater = LayoutInflater.from(context);
	}
	
	public int getCount(){
		return itens.size();
	}
	
	public ItemMainList getItem(int position){
		return itens.get(position);
	}
	
	public long getItemId(int position){
		return position;
	}
	
	public View getView(int position, View v, ViewGroup vg){
		ItemMainList item = itens.get(position);
		v = mInflater.inflate(R.layout.main_list, null);
		
		TextView t = (TextView) v.findViewById(R.id.nomefuncao);
		t.setText(item.getTexto());
		ImageView i = (ImageView) v.findViewById(R.id.imagemview);
		i.setImageResource(item.getIconRid());
		
		return v;
	}
}
